public class 作业4_2 {
    public static void main(String[] args) {


        for (int i = 1; i <= 10; i++) {
            System.out.println(i);
        }

        for (int i = 10; i >= 1; i--) {
            System.out.println(i);
        }

        int sum = 0;
        for (int i = 1; i <= 10; i++) {
            sum += i;
        }
        System.out.println("1-10之间数据之和为: " + sum);
   
        int sumEven = 0;
        for (int i = 2; i <= 100; i += 2) {
            sumEven += i;
        }
        System.out.println("1-100之间偶数和为: " + sumEven);
   
        int sumOdd = 0;
        for (int i = 1; i <= 100; i += 2) {
            sumOdd += i;
        }
        System.out.println("1-100之间奇数和为: " + sumOdd);

        int factorial = 1;
        for (int i = 1; i <= 5; i++) {
            factorial *= i;
        }
        System.out.println("5的阶乘为: " + factorial);

        for (int i = 100; i <= 999; i++) {
            int hundreds = i / 100;
            int tens = (i % 100) / 10;
            int ones = i % 10;
            if (Math.pow(hundreds, 3) + Math.pow(tens, 3) + Math.pow(ones, 3) == i) {
                System.out.println(i);
            }
            }

        int count = 0;
        for (int i = 100; i <= 999; i++) {
                int hundreds = i / 100;
                int tens = (i % 100) / 10;
                int ones = i % 10;
                if (Math.pow(hundreds, 3) + Math.pow(tens, 3) + Math.pow(ones, 3) == i) {
                    count++;
                }
         }
        System.out.println("水仙花数共有: " + count + "个");
    }
}
